package com.siyoumi.app.modules.wechat.web;

import com.siyoumi.app.modules.wechat.entity.WechatNotifyData;
import com.siyoumi.app.modules.wechat.service.WeChatEventCai;
import com.siyoumi.app.modules.wechat.service.WeChatEventMoyu;
import com.siyoumi.controller.ApiController;
import com.siyoumi.exception.EnumSys;
import com.siyoumi.util.XReturn;
import com.siyoumi.util.XStr;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/sys/wechat/api")
public class ApiWechat
        extends ApiController {
    //摸鱼排行榜
    @GetMapping("send_moyu")
    public XReturn sendMoyu() {
        //String roomId = "18360659908@chatroom";
        String roomId = input("room_id");
        if (XStr.isNullOrEmpty(roomId)) {
            return EnumSys.MISS_VAL.getR("miss room_id");
        }

        WeChatEventMoyu.getBean().send(roomId);

        return getR();
    }

    //开始猜词
    @GetMapping("begin_cai")
    public XReturn beginCai() {
        //String roomId = "18360659908@chatroom";
        String roomId = input("room_id");
        if (XStr.isNullOrEmpty(roomId)) {
            return EnumSys.MISS_VAL.getR("miss room_id");
        }

        WechatNotifyData data = new WechatNotifyData();
        data.setRoomid(roomId);
        WeChatEventCai.getBean().beginFunc(data);

        return getR();
    }
}
